const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');

const Application = sequelize.define('Application', {
  id: {
    type: DataTypes.UUID,
    defaultValue: DataTypes.UUIDV4,
    primaryKey: true
  },
  name: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '应用名称'
  },
  type: {
    type: DataTypes.ENUM('app', 'web', 'miniprogram'),
    allowNull: false,
    comment: '应用类型'
  },
  version: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '应用版本'
  },
  config: {
    type: DataTypes.JSON,
    defaultValue: {},
    comment: '应用配置'
  },
  status: {
    type: DataTypes.ENUM('active', 'inactive', 'maintenance'),
    defaultValue: 'active',
    comment: '应用状态'
  },
  description: {
    type: DataTypes.TEXT,
    comment: '应用描述'
  },
  releaseNotes: {
    type: DataTypes.TEXT,
    comment: '发布说明'
  },
  downloadUrl: {
    type: DataTypes.STRING,
    comment: '下载链接'
  },
  metadata: {
    type: DataTypes.JSON,
    defaultValue: {},
    comment: '元数据'
  }
}, {
  comment: '应用信息表'
});

module.exports = Application; 